// 辅助类型：首字母大写
// type Capitalize<S extends string> = S extends `${infer F}${infer R}`
//     ? `${Uppercase<F>}${R}`
//     : S;

// 辅助类型：首字母小写
// type Uncapitalize<S extends string> = S extends `${infer F}${infer R}`
//     ? `${Lowercase<F>}${R}`
//     : S;

export type CamelCase<S extends string> =
    S extends `${infer T}_${infer U}`
        ? `${T}${Capitalize<CamelCase<U>>}`
        : S;

// camelCase → snake_case
export type SnakeCase<S extends string> =
    S extends `${infer T}${infer U}`
        ? `${T extends Lowercase<T> ? T : `_${Lowercase<T>}`}${SnakeCase<U>}`
        : S;

// 转化为数据库model的字段写法类型
export type ToM<T> = {
    [K in keyof T as K extends string ? SnakeCase<K> : never]: T[K];
};

// 转化为表单Schema的字段写法类型
// type ToS<T> = {
//     [K in keyof T as K extends string ? CamelCase<K> : never]: T[K];
// }


